﻿<%@ Page Title="" Language="C#" MasterPageFile="//Admin/Manager.Master" AutoEventWireup="true"
    CodeBehind="UserManager.aspx.cs" Inherits="Bilyteam_Website.Admin.Users.UserManager" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1 align="center">
        Quản lý User
    </h1>
    <div style="width: 100%;">
        <asp:UpdatePanel ID="UpdatePanel4" runat="server">
            <ContentTemplate>
                <div style="width: 75%; padding-right: 2%; float: left; padding-left: 2%">
                    <h3>
                        Danh Sách User</h3>
                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
                    <asp:GridView ID="gvUser" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        OnSelectedIndexChanged="gvUser_SelectedIndexChanged" Style="margin-top: 0px"
                        EnableModelValidation="True">
                        <Columns>
                            <asp:BoundField HeaderText="ID" DataField="UserID" />
                            <asp:BoundField HeaderText="Tên Đăng Nhập" DataField="Username" />
                            <asp:BoundField HeaderText="Họ" DataField="LastName" />
                            <asp:BoundField HeaderText="Tên" DataField="FirstName" />
                            <asp:BoundField HeaderText="CMND" DataField="Identity" />
                            <asp:BoundField HeaderText="Ngày Sinh" DataField="Birthday" />
                            <asp:BoundField HeaderText="Địa Chỉ" DataField="Address" />
                            <asp:BoundField HeaderText="Điện thoại" DataField="Phone" />
                            <asp:BoundField HeaderText="Email" DataField="Email" />
                            <asp:BoundField HeaderText="Phân Quyền" DataField="RoleName" />
                            <asp:BoundField HeaderText="Trạng Thái" DataField="Status" />
                            <asp:BoundField DataField="Password" ShowHeader="False" Visible="False" />
                            <asp:ButtonField ButtonType="Button" Text="Edit" CommandName="select" />
                        </Columns>
                    </asp:GridView>
                    <table>
                        <tr>
                            <td>
                                BirthDay:
                            </td>
                            <td>
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                    <ContentTemplate>
                                        <asp:DropDownList ID="ddlDay" runat="server" ValidationGroup="User">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlMonth" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlMonth_SelectedIndexChanged"
                                            ValidationGroup="User">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlYear" runat="server" ValidationGroup="User">
                                        </asp:DropDownList>
                                    </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="ddlMonth" runat="server" />
                                    </Triggers>
                                </asp:UpdatePanel>
                            </td>
                            <td>
                                Username:
                            </td>
                            <td>
                                <asp:TextBox ID="txtUser" runat="server" ValidationGroup="User"></asp:TextBox>
                            </td>
                            <td>
                                Password:
                            </td>
                            <td>
                                <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" ValidationGroup="User"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtUser"
                                    Display="Dynamic" ErrorMessage="Username phải nhập" ValidationGroup="User"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtUser"
                                    ErrorMessage="Username phải từ 6-32 ký tự" ValidationExpression="\w{6,32}" ValidationGroup="User"></asp:RegularExpressionValidator>
                            </td>
                            <td colspan="2">
                                <asp:RegularExpressionValidator ControlToValidate="txtPassword" ID="RegularExpressionValidator2"
                                    ValidationExpression="\w{6,32}" runat="server" ErrorMessage="Password phải từ 6-32 ký tự"
                                    ValidationGroup="User"></asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Identity Code:
                            </td>
                            <td>
                                <asp:TextBox ID="txtIdentity" runat="server" ValidationGroup="User"></asp:TextBox>
                            </td>
                            <td>
                                First Name:
                            </td>
                            <td>
                                <asp:TextBox ID="txtFirstName" runat="server" ValidationGroup="User"></asp:TextBox>
                            </td>
                            <td>
                                Last Name:
                            </td>
                            <td>
                                <asp:TextBox ID="txtLastName" runat="server" ValidationGroup="User"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtIdentity"
                                    Display="Dynamic" ErrorMessage="Identity Code phải nhập" ValidationGroup="User"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="txtIdentity"
                                    ErrorMessage="Identity Code phải 9 chữ số" ValidationExpression="[0-9]{9}" ValidationGroup="User"></asp:RegularExpressionValidator>
                            </td>
                            <td colspan="2">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtFirstName"
                                    Display="Dynamic" ErrorMessage="First Name phải nhập" ValidationGroup="User"></asp:RequiredFieldValidator>
                            </td>
                            <td colspan="2">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtLastName"
                                    Display="Dynamic" ErrorMessage="Last Name phải nhập" ValidationGroup="User"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Phone Number:
                            </td>
                            <td>
                                <asp:TextBox ID="txtPhone" runat="server" ValidationGroup="User"></asp:TextBox>
                            </td>
                            <td>
                                Address:
                            </td>
                            <td>
                                <asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine" ValidationGroup="User"></asp:TextBox>
                            </td>
                            <td>
                                <asp:Button ID="btnSubmitUser" runat="server" OnClick="btnSubmitUser_Click" Text="Submit"
                                    ValidationGroup="User" />
                                <asp:Button ID="btnResetUser" runat="server" Text="Reset" 
                                    ValidationGroup="User" onclick="btnResetUser_Click" />
                                <asp:Button ID="btnDeleteUser" runat="server" Enabled="false" Text="Delete" 
                                    onclick="btnDeleteUser_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtPhone"
                                    Display="Dynamic" ErrorMessage="Phone Number phải nhập" ValidationGroup="User"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="txtPhone"
                                    ErrorMessage="Sai Định Dạng số Phone" ValidationExpression="0{1}[0-9]{1,10}"
                                    ValidationGroup="User"></asp:RegularExpressionValidator>
                            </td>
                            <td colspan="2">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtAddress"
                                    Display="Dynamic" ErrorMessage="Address phải nhập" ValidationGroup="User"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Role:
                            </td>
                            <td>
                                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                                    <ContentTemplate>
                                        <asp:DropDownList ID="ddlRole" runat="server" ValidationGroup="User">
                                        </asp:DropDownList>
                                    </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="btnSubmitRole" />
                                    </Triggers>
                                </asp:UpdatePanel>
                            </td>
                            <td>
                                Email:
                            </td>
                            <td>
                                <asp:TextBox ID="txtEmail" runat="server" ValidationGroup="User"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtEmail"
                                    Display="Dynamic" ErrorMessage="Email phải nhập" ValidationGroup="User"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" ControlToValidate="txtEmail"
                                    ErrorMessage="Sai Định Dạng Email" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                    ValidationGroup="User"></asp:RegularExpressionValidator>
                            </td>
                        </tr>
                    </table>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnSubmitUser" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <div style="">
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                <h3>
                    Danh Sách Roles</h3>
                <asp:GridView ID="gvRole" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                    OnSelectedIndexChanged="gvRole_SelectedIndexChanged" EnableModelValidation="True">
                    <Columns>
                        <asp:BoundField HeaderText="ID" DataField="RoleID" />
                        <asp:BoundField HeaderText="Tên quyền" DataField="RoleName" />
                        <asp:BoundField HeaderText="Trạng thái" DataField="Status" />
                        <asp:ButtonField ButtonType="Button" Text="Edit" CommandName="select" />
                    </Columns>
                </asp:GridView>
                <table>
                    <tr>
                        <td>
                            Role Name:
                        </td>
                        <td>
                            <asp:TextBox ID="txtRoleName" runat="server" ValidationGroup="Role"></asp:TextBox>
                        </td>
                        <td colspan="2">
                            <asp:RequiredFieldValidator ControlToValidate="txtRoleName" ID="RequiredFieldValidator9"
                                runat="server" ErrorMessage="Role name không được trống" ValidationGroup="Role"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Button ID="btnSubmitRole" runat="server" Text="Submit" OnClick="btnSubmitRole_Click"
                                ValidationGroup="Role" />
                        </td>
                        <td>
                            <asp:Button ID="btnDelete" runat="server" Text="Delete" ValidationGroup="Role" OnClick="btnDelete_Click" />
                            <asp:Button ID="btnRollBack" runat="server" Text="Rollback" OnClick="btnRollBack_Click"
                                ValidationGroup="Role" />
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnSubmitRole" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <%--</div>--%>
</asp:Content>
